package com.huamao.niceman.scrollviewpager.home.view;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.huamao.niceman.scrollviewpager.R;
import com.huamao.niceman.scrollviewpager.base.BaseFragment;
import com.huamao.niceman.scrollviewpager.base.BasePresent;
import com.huamao.niceman.scrollviewpager.home.present.ConstellationPresent;
import com.huamao.niceman.scrollviewpager.model.DayModel;
import com.huamao.niceman.scrollviewpager.utils.FragmentInterface;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

/**
 * Created by LuanXianSheng on 2017/6/13.
 * 星座
 */

public class ConstellationFragment extends BaseFragment implements FragmentInterface{
    private AppCompatActivity act ;
    private ConstellationPresent mPresent ;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        act = (AppCompatActivity) context ;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        creatPresent();
        return inflater.inflate(R.layout.frag_constellation,null);
    }

    @Override
    public BasePresent creatPresent() {
        mPresent = new ConstellationPresent(this) ;
        return mPresent;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        init();
        setData();
    }

    @Override
    public void init() {

    }

    @Override
    public void setData() {
        String name = null ;
        try {
             name =  URLDecoder.decode("白羊座", "utf-8") ;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        mPresent.getInternetData(name,"today");
    }

    @Override
    public void getData(Object object) {
        DayModel model = (DayModel) object;
    }
}
